package top.appx.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import top.appx.exception.MsgException;
import top.appx.util.ResultUtil;
import top.appx.vo.Result;

import javax.servlet.http.HttpServletResponse;

/**
 * Created by lhzxd on 2017/5/3.
 */
@RestControllerAdvice
public class MsgExceptionHandler {
    private static final Logger logger = LoggerFactory.getLogger(MsgExceptionHandler.class);

    @ExceptionHandler(value = MsgException.class)
    public ResponseEntity handle(MsgException ex){
        logger.info("MsgException handle method execs:"+ex.getMessage());
        return new ResponseEntity(ex.getHttpStatus());
    }

}
